<?php
    $openid = $_GET["openid"];
    // $openid = "o4vyI5fHdfn3J4q0jxzFfgpy8i7g";
    $a = mysqli_connect("localhost","root","gala123456");
    $db = mysqli_select_db($a,"sheep");
    $sql = "SELECT `monitor_url`,`business` FROM `sheep` WHERE `sheep_select` = '$openid'";
    $query = mysqli_query($a,$sql);
    $url = array();
    $business = array();
    $address = array();
    while ($row = mysqli_fetch_row($query)) {
        $ding = 0;
        foreach ($row as $nei) {
            if ($ding == 0) {
                array_push($url,$nei);
            }else{
                array_push($business,$nei);
            }
            $ding++;
        }
    }
    for ($i = 0;$i < count($business);$i++) {
        $sql1 = "SELECT `business_address` FROM `business` WHERE `business_name` = '".$business[$i]."'";
        $query1 = mysqli_query($a,$sql1);
        while ($row1 = mysqli_fetch_row($query1)) {
            foreach ($row1 as $nei1) {
                array_push($address,$nei1);
            }
        }
    }
    $arr = array(
        "url" => $url,
        "business" => $business,
        "address" => $address
    );
    echo json_encode($arr);
?>